package com.jinsi.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * Date : 2022/6/29 15:01
 * 小南不难
 **/
public class MapReturn {
    //结果集返回
    private static Map<String,Object> map;

    //构造器私有化
    private MapReturn(){};

    //返回成功信息，状态码200
    public static Map<String,Object> getSuccess(Object o){
        map = new HashMap<>();
        map.put("state","200");
        map.put("msg","成功");
        map.put("data",o);
        return map;
    }

    //返回失败信息，状态码500
    public static Map<String,Object> getError(Object o){
        map = new HashMap<>();
        map.put("state","500");
        map.put("msg","失败");
        map.put("data",o);
        return map;
    }

    //自定义返回值
    public static Map<String,Object> getCustom(String state,String msg,Object o){
        map = new HashMap<>();
        map.put("state",state);
        map.put("msg",msg);
        map.put("data",o);
        return map;
    }

    //自定义layuiTable返回值
    public static Map<String,Object> getTable(String code,String msg,int count,Object data){
        map = new HashMap<>();
        map.put("code",code);
        map.put("msg",msg);
        map.put("count",count);
        map.put("data",data);
        return map;
    }
}
